Uprava Easy populate


toto vloi niekde na zaiatok ridok 30 a 40 podla verzie ale je to skoro jedno niekde pred 
require_once ('includes/application_top.php');




// ##### zkopirovana funkce z function_categories.php pro pouziti v tomto scriptu #####
	function zen_get_subcategories(&$subcategories_array, $parent_id = 0) {
    global $db;
    $subcategories_query = "select categories_id
                            from " . TABLE_CATEGORIES . "
                            where parent_id = '" . (int)$parent_id . "'";

    $subcategories = $db->Execute($subcategories_query);

    while (!$subcategories->EOF) {
      $subcategories_array[sizeof($subcategories_array)] = $subcategories->fields['categories_id'];
      if ($subcategories->fields['categories_id'] != $parent_id) {
        zen_get_subcategories($subcategories_array, $subcategories->fields['categories_id']);
      }
      $subcategories->MoveNext();
    }
  }
//---------------------------------------------------------------------------------------




najst toto v case 'full' a za to:

WHERE
p.products_id = ptoc.products_id AND
ptoc.categories_id = subc.categories_id
";

treba vloi toto:


//---------------------------------------------------------------------------------------
if (isset($_GET["p_m"])) {
				$p_m = $_GET["p_m"];
				
				if ((int)($p_m) != 0) {
					$filelayout_sql .= "AND p.manufacturers_id = " . $p_m;
				}
			}
			if (isset($_GET["cats"])) {
				$cats = $_GET["cats"];
				
				if ((int)$cats !=0) {
					$vsechny_podkategorie = array();
					zen_get_subcategories($vsechny_podkategorie, $cats);
					
					if (count($vsechny_podkategorie) > 1) {
					$filelayout_sql .= " AND (";
					for ($i=0, $n=sizeof($vsechny_podkategorie); $i<$n; $i++ ) {
						if ($i == 0) {
							$filelayout_sql .= " subc.categories_id = " . $vsechny_podkategorie[$i] . " ";
						} else {
							$filelayout_sql .= " OR subc.categories_id = " . $vsechny_podkategorie[$i] . " ";
						}
						
					}
					$filelayout_sql .= ")";
					} else {
						$filelayout_sql .= " AND subc.categories_id = " . $cats;
					}
				}
			}
// ---------------------------------------------------------------------------------------


najs toto v case 'priceqty':

$filelayout_sql = "SELECT
			p.products_id as v_products_id,
			p.products_model as v_products_model,
			p.products_price as v_products_price,
			p.products_tax_class_id as v_tax_class_id,
			p.products_quantity as v_products_quantity
			FROM
			".TABLE_PRODUCTS." as p
			";


a nahradi tmto:

// ---------------------------------------------------------------------------------------
$filelayout_sql = "SELECT
			p.products_id as v_products_id,
			p.products_model as v_products_model,
			p.products_price as v_products_price,
			p.products_tax_class_id as v_tax_class_id,
			p.products_quantity as v_products_quantity
			FROM
			".TABLE_PRODUCTS." as p,
			".TABLE_CATEGORIES." as subc,
			".TABLE_PRODUCTS_TO_CATEGORIES." as ptoc
			WHERE
			p.products_id = ptoc.products_id AND
			ptoc.categories_id = subc.categories_id
			";
			if (isset($_GET["p_m"])) {
				$p_m = $_GET["p_m"];
				
				if ((int)($p_m) != 0) {
					$filelayout_sql .= "AND p.manufacturers_id = " . $p_m;
				}
			}
			if (isset($_GET["cats"])) {
				$cats = $_GET["cats"];
				
				if ((int)$cats !=0) {
					$vsechny_podkategorie = array();
					zen_get_subcategories($vsechny_podkategorie, $cats);
					
					if (count($vsechny_podkategorie) > 1) {
					$filelayout_sql .= " AND (";
					for ($i=0, $n=sizeof($vsechny_podkategorie); $i<$n; $i++ ) {
						if ($i == 0) {
							$filelayout_sql .= " subc.categories_id = " . $vsechny_podkategorie[$i] . " ";
						} else {
							$filelayout_sql .= " OR subc.categories_id = " . $vsechny_podkategorie[$i] . " ";
						}
						
					}
					$filelayout_sql .= ")";
					} else {
						$filelayout_sql .= " AND subc.categories_id = " . $cats;
					}
				}
			}
// ---------------------------------------------------------------------------------------



potom u iba najs toto:
<b>Download EP and Froogle Files</b>
a za to vloi toto:


// ---------------------------------------------------------------------------------------
<!-- bof -  vyrobci a kategorie -->
											<fieldset style="width: 430px">
											<legend>Export tovaru - kombincia vybranho vrobcu a kategrie</legend>
											<?php 
	$mansql = "select m.manufacturers_id, m.manufacturers_name
           from " . TABLE_MANUFACTURERS . " m
           order by manufacturers_name";
	$vysledek = $db->Execute($mansql);
		$vystup = '<option value="0">All manufacturer</option>';
		while (!$vysledek->EOF) {
			$vystup .= '<option value="' . $vysledek->fields['manufacturers_id'] . '">' . $vysledek->fields['manufacturers_name'] . '</option>\n';
      $vysledek->MoveNext();
    }
											?>
											<form action="" method="get" name="vyrobci" id="seznamv">
												<select name="seznamvyrobcu" id="sv_id" size="1" onChange="changeCategories();">
													<?php
														echo $vystup;
													?>
												</select>	
												<?php
	//	echo zen_draw_form('goto', FILENAME_CATEGORIES, '', 'get');
    //echo zen_hide_session_id();
    echo zen_draw_pull_down_menu('cPath', zen_get_category_tree(), $current_category_id, 'onChange="changeCategories();" id="kategories"');
?>
																			
											<br /><br /><a href="easypopulate.php?download=stream&dltype=full" id="full_ids">Download <b>Complete</b> .csv file to edit</a><br />
											<a href="easypopulate.php?download=stream&dltype=priceqty" id="priceqty_ids">Download <b>Model/Price/Qty</b> .csv file to edit</a>
											</form>
											<script language="javascript">
												$cats = document.getElementById("full_ids");
												$priceqty = document.getElementById("priceqty_ids");
												var $old_cats_href = $cats.href;
												var $old_priceqty_href = $priceqty.href;
												
												function changeCategories() {
													$cps = document.getElementById("kategories");
													$cats = document.getElementById("full_ids");
													$priceqty = document.getElementById("priceqty_ids");
													$sv = document.getElementById("sv_id");
													$cats.href = $old_cats_href+'&cats='+$cps.value+'&p_m='+$sv.value;
													$priceqty.href = $old_priceqty_href+'&cats='+$cps.value+'&p_m='+$sv.value;
												}
											</script>
											</fieldset><br />
										<!-- eof -  vyrobci a kategorie -->
// ---------------------------------------------------------------------------------------